#include <iostream> 

using namespace std;

const int N = 110;

char s[N][N];
int n, m;
int cnt[N][N];

int dx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy[8] = {1, 1, 1, 0, -1, -1, -1, 0};

int main()
{
	cin >> n >> m;
	
	for (int i = 0; i < n; i ++ )
	{
		for (int j = 0; j < m; j ++ )
		{
			cin >> s[i][j];
		}
	}
	
	for (int i = 0; i < n; i ++ )
	{
		for (int j = 0; j < m; j ++ )
		{
			for (int k = 0; k < 8; k ++ )
			{
				if (s[i][j] != '*') continue;
				int ax = i + dx[k];
				int ay = j + dy[k];
				
				if (ax < 0 || ax >= n || ay < 0 || ay >= m ) continue;
				
				cnt[ax][ay] ++ ;
			}
		}
	}
	
	for (int i = 0; i < n; i ++ )
	{
		for (int j = 0; j < m; j ++ )
		{
			if (s[i][j] == '*') cout << '*';
			else cout << cnt[i][j];
		}
		puts("");
	}
	
	return 0;
}
